<template>
	<view class="content">
			 
			 
			<view class="cu-form-group">
				<view class="title">追加金额</view>
				<input v-model="form.money" placeholder="请输入追加金额"  name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">追加日期</view>
				 <picker mode="date" :value="form.addTime" start="2020-01-01" end="2060-12-31" @change="DateChange">
				 	<view class="picker">
				 		{{form.addTime}}
				 	</view>
				 </picker>
			</view>
			 <view class="cu-form-group">
			 	<view class="title">备注</view>
			 	<input v-model="form.note" placeholder="请输入备注" name="input"></input>
			 </view>
			<view class="btn-box">
				<view class="submit-btn" @click="submit">保存</view>
			</view>
		 
	</view>
</template>

<script>
	import api from '@/api/api.js';
	export default {
		data() {
			return {
				form:{
					contractId:undefined,
					money:0,
					addTime:undefined,
				}
			}
		},
		onLoad(options) {
			this.form.contractId=options.contractId;
			// 修改顶部导航背景色
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: '#39b54a',
				animation: {
					duration: 400,
					timingFunc: 'easeIn'
				}
			})
			let date = new Date();
			this.form.addTime=this.utils.dateFormat("YYYY-mm-dd", date);
		},
		methods: {
			DateChange(e) {
				this.form.addTime = e.detail.value
			},
			submit(){
				if (this.utils.isEmpty(this.form.money)) {
					uni.showToast({
						title: "请输入追加金额",
						icon: 'none',
					});
					return
				}
				api.addMoney(this.form).then(
					res => {
						if(res.code==200){
							uni.showToast({
								title: '提交成功',
								duration: 2000
							});
							setTimeout(function() {
								uni.navigateBack({
								  success: () => {
								  }
								})
							}, 500);
						}
						else{
							uni.showToast({
								title: res.msg,
								icon: 'none',
							});
						}
						
					},
					rej => {}
				);
				
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.content{
		margin-top: 20upx;
		.floow-cont{
			flex-direction: column;
			background-color: #ffffff;
			padding: 1rpx 30rpx;
			margin-top: 20upx;
			.title{
				text-align: justify;
				padding-right: 30upx;
				font-size: 30upx;
				position: relative;
				height: 60upx;
				line-height: 60upx;
			}
			 
		}
	}
	.btn-box{
		padding: 20upx 24upx;
		.submit-btn{
			height: 80upx;
			line-height: 80upx;
			text-align: center;
			font-size: 28upx;
			color: #fff;
			border-radius: 8upx;
			background: #39b54a;
		}
	}
</style>
